package org.seedframework.sharding.mybatis;

import org.seedframework.sharding.strategy.ScatterStrategy;

public class ScatterRoutingDefinition {

    private String key;

    private String value;

    private ScatterStrategy strategy;

    private String[] fieldsRoute;

    public ScatterRoutingDefinition(String key, Object strategy, String[] fieldsRoute) {
        this.key = key;
        this.strategy = (ScatterStrategy)strategy;
        this.fieldsRoute = fieldsRoute;
    }


    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public ScatterStrategy getStrategy() {
        return strategy;
    }

    public void setStrategy(ScatterStrategy strategy) {
        this.strategy = strategy;
    }

    public String[] getFieldsRoute() {
        return fieldsRoute;
    }

    public void setFieldsRoute(String[] fieldsRoute) {
        this.fieldsRoute = fieldsRoute;
    }


    public String dataSource() {
        return strategy.dataSource(value);
    }

    public String tableSuffix() {
        return strategy.tableSuffix(value);
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }
}
